<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>2322：[BeiJing2011]梦想封印</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[BeiJing2011]梦想封印</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[BeiJing2011]梦想封印</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                [BeiJing2011]梦想封印                </h1>
                <p>时间限制：20s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：128MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><h2 style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-weight: normal; font-size: 12pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></h2>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">渐渐地，</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Magic&nbsp;Land</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">上的人们对那座岛屿上的各种现象有了深入的了解。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">为了分析一种奇特的称为梦想封印（</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Fantasy&nbsp;Seal</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">）的特技，需要引入如下的概念：</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">每一位魔法的使用者都有一个&ldquo;魔法脉络&rdquo;，它决定了可以使用的魔法的种类。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">一般地，一个&ldquo;魔法脉络&rdquo;可以看作一个无向图，有</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">N</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">个结点及</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">M</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">条边，将结点编号为</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">1~N</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">，其中有一个结点是特殊的，称为</span><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">核心</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">（</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Kernel</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">），</span><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">记作<font face="Times New Roman">1</font><font face="宋体">号结点</font></span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">。每一条边有一个固有（即生成之后再也不会发生变化的）权值，是一个不超过</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">U</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">的自然数。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">每一次魔法驱动，可看作是</span><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">由核心（</span><span style="font-weight: bold; font-size: 12pt; font-style: italic; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">Kernel</span><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">）出发</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">的一条有限长的道路（</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Walk</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">），</span><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">可以经过一条边多次</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">，所驱动的魔法类型由以下方式给出：</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">将经过的每一条边的权值异或（</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">xor</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">）起来，得到</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">s</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">如果</span><span style="font-weight: bold; font-size: 12pt; font-style: italic; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">s</span><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">是</span><span style="font-weight: bold; font-size: 12pt; font-style: italic; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">0</span><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">，则驱动失败</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">，否则将驱动编号为</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">s</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">的魔法（每一个正整数编号对应了唯一一个魔法）。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">需要注意的是，如果经过了一条边多次，则每一次都要计入<font face="Times New Roman">s</font><font face="宋体">中。</font></span><span style="font-weight: bold; font-size: 12pt; font-family: 'Times New Roman'; text-decoration: underline; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">这样，魔法脉络决定了可使用魔法的类型，当然，由于魔法与其编号之间的关系尚未得到很好的认知，此时人们仅仅关注可使用魔法的种类数。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">梦想封印可以看作是对&ldquo;魔法脉络&rdquo;的破坏：</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">该特技作用的结果是，&ldquo;魔法脉络&rdquo;中的一些边逐次地消失。</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'"> </span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">我们记总共消失了</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Q</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">条边，按顺序依次为</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Dis</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">、<font face="Times New Roman">Dis</font></span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">2</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">、&hellip;&hellip;、<font face="Times New Roman">Dis</font></span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Q</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">给定了以上信息，你要计算的是梦想封印作用过程中的效果，这可以用</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Q+1</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">个自然数来描述：</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Ans</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">0</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">为初始时可以使用魔法的数量。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Ans</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">为</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Dis</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">被破坏（</span><span style="font-weight: bold; font-size: 12pt; font-family: '宋体'; text-decoration: underline; mso-spacerun: 'yes'">即边被删去</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">）后可以使用魔法的数量。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Ans</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">2</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">为</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Dis</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">及</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Dis</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">2</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">均被破坏后可使用魔法的数量。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">&hellip;&hellip;</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Ans</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Q</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">为</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Dis</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">、</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Dis</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">2</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">、&hellip;&hellip;、</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Dis</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Q</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">全部被破坏后可以使用魔法的数量。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-align: left"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<!--EndFragment--></p><hr/><h3>输入格式</h3><p><p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">第一行包含</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">三</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">个</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">正</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">整数</span><span style="font-size: 12pt; font-style: italic; font-family: 'Times New Roman'; mso-spacerun: 'yes'">N</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">、<font face="Times New Roman">M</font><font face="宋体">、</font><font face="Times New Roman">Q</font></span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">接下来的</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">M</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">行，每行包含</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">3</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">个整数，</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Ai</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">、</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Bi</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">、</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">W</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">，表示一条权为</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">W</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">的与结点</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">A</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">、</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">B</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">关联的无向边，其中</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">W</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">是不超过</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">U</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">的自然数。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">接下来</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Q</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">行，每行一个整数：</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Dis</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">i</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p></p><hr/><h3>输出格式</h3><p><p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">一共包</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Q+1</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">行，依次为</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Ans</span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">0</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">、<font face="Times New Roman">Ans</font></span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">1</span><span style="font-size: 12pt; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">、&hellip;&hellip;、<font face="Times New Roman">Ans</font></span><span style="font-size: 12pt; vertical-align: sub; font-style: italic; font-family: '宋体'; mso-spacerun: 'yes'">Q</span><span style="font-size: 12pt; font-family: '宋体'; mso-spacerun: 'yes'">。</span><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<h2 style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 12pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></h2></p><hr/><h3>样例输入</h3><pre>【输入样例1】
3 3 2

1 2 1

2 3 2

3 1 4

1

3

【输入样例2】
5 7 7

1 2 1

1 3 1

2 4 2

2 5 2

4 5 4

5 3 9

4 3 1

7

6

5

4

3

2

1

</pre><hr/><h3>样例输出</h3><pre>【输出样例1】
5

2

0

【样例1解释】
初始时可使用编号为1、3、4、6、7的魔法。

在删去第1条边（连结1、2结点的边）后，可使用4和6号魔法。

第3条边（连结第1、3结点的边）也被删去后，核心（Kernel）即结点1孤立，易知此时无法使用魔法。

【输出样例2】
15

11

5

2

2

1

1

0


</pre><hr/><h3>提示</h3><p><p>【数据规模和约定】<br />
所有数据保证该无向图不含重边、自环。</p>
<p>所有数据保证不会有一条边被删除多次，即对于不同i和j，有Disi&ne;Disj</p>
<p>30%的数据中N &le; 50，M &le; 50，Q &le;50，U&le;100；</p>
<p>60%的数据中N &le; 300，M &le; 300，Q &le;50，U&le;10^9；</p>
<p>80%的数据中N &le; 300，M &le; 5000，Q &le;5000，U&le;10^18；</p>
<p>100%的数据中N &le; 5000，M &le; 20000，Q &le;20000，U&le;10^18；</p>
<p></p></p><hr/><h3>题目来源</h3><p>Day3</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=2322" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=2322" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>